The invention relates to a method for performing a query on a document created using a Markup language and to software and hardware configured to carry out the method. More specifically, the invention enables the time required to perform a query to be reduced and enables the size of the memory required to perform the query to be reduced as compared to the related art.
There are two basic ways to interface a parser with an application, namely, using an object-based interface and an event-based interface. A Markup language that is becoming popular at the time of writing this application is XML (Extensible Markup Language), and two types of interfaces have been developed for use with XML. The DOM (Document Object Model) interface is an object-based interface and the SAX (Simple Application Programming Interface) is an event-based interface. Related art methods of searching a Markup document using either of these interfaces involve constructing a tree representing the document to be searched.
With a parser using an object-based interface, such as the DOM, the parser explicitly builds a tree of objects that contains all of the elements of the XML document. In contrast, a SAX parser usually accepts a document handler that receives callbacks invoked by the SAX parser. The callbacks inform the document handler of events that are read by the SAX parser. Such events can be, for example, a start-tag and an end-tag. The sequence of callbacks allows the document handler to build a tree of objects of all of the XML elements as they appear in the XML document. However, constructing such a tree requires a great deal of memory and time, and a query, typically, runs several times over the constructed tree.